package top.datacluster.basic.algorithm.leetcode.dynamic;

public class LeetCode213 {

    public int maxSubArray(int[] nums) {
        int temp = nums[0];
        int max = nums[0];
        for (int i = 1; i < nums.length; i++){
            temp = Math.max(nums[i], temp + nums[i]);
            if (temp > max){
                max = temp;
            }
        }
        return max;
    }
}
